<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="ExpedienteListForm">

        <p:panel header="#{myBundle.ListExpedienteTitle}">
            <p:contextMenu id="ExpedienteDataTableContextMenu" for="datalist">  
                <p:menuitem value="#{myBundle.Create}" onclick="document.getElementById('ExpedienteListForm:createButton').click();" icon="ui-icon-plus"/>
                <p:menuitem value="#{myBundle.View}" onclick="document.getElementById('ExpedienteListForm:viewButton').click();" icon="ui-icon-search"/>
                <p:menuitem value="#{myBundle.Edit}" onclick="document.getElementById('ExpedienteListForm:editButton').click();" icon="ui-icon-pencil"/>
                <p:menuitem value="#{myBundle.Delete}" onclick="document.getElementById('ExpedienteListForm:deleteButton').click();" icon="ui-icon-trash"/>
                <p:separator/>
                <p:menuitem value="#{myBundle.ExpedienteMenuItem_tipoExpedienteId}" icon="ui-icon-search"  actionListener="#{expedienteController.prepareTipoExpedienteId}" update=":TipoExpedienteViewForm" oncomplete="TipoExpedienteViewDialog.show()" disabled="#{empty expedienteController.selected.tipoExpedienteId}"/>  
                <p:menuitem value="#{myBundle.ExpedienteMenuItem_barrioId}" icon="ui-icon-search"  actionListener="#{expedienteController.prepareBarrioId}" update=":BarrioViewForm" oncomplete="BarrioViewDialog.show()" />  
                
                
                <p:menuitem value="#{myBundle.ExpedienteMenuItemPases}" icon="ui-icon-search"  actionListener="#{expedienteBean.aPases}"  >
                    <f:attribute name="expediente" value="#{expedienteBean.expedienteSelected}" />
                </p:menuitem>
                
            </p:contextMenu>
            <p:dataTable id="datalist"
                         value="#{expedienteBean.expedientes}"
                         var="item"
                         rowKey="#{item.id}"
                         paginator="true"
                         rows="6"
                         rowsPerPageTemplate= "3,6" 
                         selectionMode="single"
                         selection="#{expedienteBean.expedienteSelected}">

                <p:ajax event="rowSelect"   update=":ExpedienteListForm:createButton :ExpedienteListForm:viewButton :ExpedienteListForm:editButton :ExpedienteListForm:deleteButton :ExpedienteListForm:ExpedienteDataTableContextMenu" listener="#{expedienteController.resetParents}"/>
                <p:ajax event="rowUnselect" update=":ExpedienteListForm:createButton :ExpedienteListForm:viewButton :ExpedienteListForm:editButton :ExpedienteListForm:deleteButton :ExpedienteListForm:ExpedienteDataTableContextMenu" listener="#{expedienteController.resetParents}"/>
                <p:ajax event="rowDblselect" onsuccess="document.getElementById('ExpedienteListForm:viewButton').click();"/>

                <p:column sortBy="#{item.numero}" filterBy="#{item.numero}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListExpedienteTitle_numero}"/>
                    </f:facet>
                    <h:outputText value="#{item.numero}"/>
                </p:column>


                <p:column sortBy="#{item.partido}" filterBy="#{item.partido}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListExpedienteTitle_partido}"/>
                    </f:facet>
                    <h:outputText value="#{item.partido}"/>
                </p:column>


                <p:column sortBy="#{item.alcance}" filterBy="#{item.alcance}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListExpedienteTitle_alcance}"/>
                    </f:facet>
                    <h:outputText value="#{item.alcance}"/>
                </p:column>


                <p:column sortBy="#{item.cuerpo}" filterBy="#{item.cuerpo}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListExpedienteTitle_cuerpo}"/>
                    </f:facet>
                    <h:outputText value="#{item.cuerpo}"/>
                </p:column>


                <p:column sortBy="#{item.extracto}" filterBy="#{item.extracto}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListExpedienteTitle_extracto}"/>
                    </f:facet>
                    <h:outputText value="#{item.extracto}"/>
                </p:column>


                <p:column sortBy="#{item.fechaInicio}" filterBy="#{item.fechaInicio}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListExpedienteTitle_fechaInicio}"/>
                    </f:facet>
                    <h:outputText value="#{item.fechaInicio}">
                        <f:convertDateTime pattern="MM/dd/yyyy" />
                    </h:outputText>
                </p:column>

                <!--
                                    <p:column sortBy="#{item.tipoExpediente}" filterBy="#{item.tipoExpediente}">
                                        <f:facet name="header">
                                            <h:outputText value="#{myBundle.ListExpedienteTitle_tipoExpediente}"/>
                                        </f:facet>
                                        <h:outputText value="#{item.tipoExpediente}"/>
                                    </p:column>
                -->
                <!--
                                    <p:column sortBy="#{item.numero}" filterBy="#{item.numero}">
                                        <f:facet name="header">
                                            <h:outputText value="#{myBundle.ListExpedienteTitle_numero}"/>
                                        </f:facet>
                                        <h:outputText value="#{item.numero}"/>
                                    </p:column>
                -->
                <!--
                                    <p:column sortBy="#{item.tipoExpedienteId.id}" filterBy="#{item.tipoExpedienteId.id}">
                                        <f:facet name="header">
                                            <h:outputText value="#{myBundle.ListExpedienteTitle_tipoExpedienteId}"/>
                                        </f:facet>
                                        <h:outputText value="#{item.tipoExpedienteId.id}"/>
                                    </p:column>
                -->
                <!--
                                    <p:column sortBy="#{item.barrioId.id}" filterBy="#{item.barrioId.id}">
                                        <f:facet name="header">
                                            <h:outputText value="#{myBundle.ListExpedienteTitle_barrioId}"/>
                                        </f:facet>
                                        <h:outputText value="#{item.barrioId.id}"/>
                                    </p:column>
                -->

            </p:dataTable>


            <p:commandButton id="createButton"                             icon="ui-icon-plus"   value="#{myBundle.Create}" actionListener="#{expedienteBean.expedientePrepareCreate}" update=":ExpedienteCreateForm" oncomplete="PF('ExpedienteCreateDialog').show()"/>
            <p:commandButton id="viewButton"   style="visibility: hidden;" icon="ui-icon-search" value="#{myBundle.View}" update=":ExpedienteViewForm" oncomplete="ExpedienteViewDialog.show()" disabled="#{empty expedienteController.selected}"/>

            <p:commandButton id="editButton"   style="visibility: hidden;" icon="ui-icon-pencil" value="#{myBundle.Edit}" update=":ExpedienteEditForm" oncomplete="ExpedienteEditDialog.show()" disabled="#{empty expedienteController.selected}"/>
            <p:commandButton id="deleteButton" style="visibility: hidden;" icon="ui-icon-trash"  value="#{myBundle.Delete}" actionListener="#{expedienteBean.eliminarExpediente}" update=":growl,datalist" />

        </p:panel>
    </h:form>

</ui:composition>